package Leetcode;

import priority_queue.PriorityQueue;

import java.util.Arrays;

/**
 * 最后一块石头的重量
 */
public class Num_1046lastStoneWeight {
    public int lastStoneWeight(int[] stones) {
       if (stones.length==2){
           return Math.abs(stones[1]-stones[0]);
       } else if (stones.length==1) {
           return stones[0];
       }else if (stones.length==0){
           return 0;
       }
       int l=stones.length;
        for (int i = 0; i <l-1 ; i++) {
            Arrays.sort(stones);
            stones[l-1]=stones[l-1]-stones[l-2];
            stones[l-1]=0;
        }
        return stones[l-1];
    }
}
